<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<!-- jqgrid-->
<link href="${basePath}/css/plugins/jqgriddemo/css/ui.jqgrid-bootstrap.min.css" rel="stylesheet" />
<!doctype html>
<html>
<head>
	<style type="text/css">
	   *{
	      margin: 0px;
	      padding: 0px;
	      font-size: 12px;
	   }
	</style>
</head>
<body class="gray-bg">
<div class="creditbody">
    <div class="iboxtitle">
        <span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;业务受理  >业务申请 >征信查询&反馈</span>
    </div>
    <div class="ibox-content ibox-zxsearchqu ">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-3">
	           	 <div class="row">
	           	 	<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">  
	             	   <label class="sr-only">客户名：</label>
	                 <input type="text" placeholder="客户名" id="customerName" name="customerName" class="form-control">
	               </div>
	               <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">  
	                 <label class="sr-only">业务员：</label>
	                 <input type="text" placeholder="业务员" id="salesmanName" name="salesmanName" class="form-control">
	                </div> 
	             </div>     
            </div>
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-2">
	            <select class="select-control" id="bankName" name="bankName">
	             	<input type="hidden" id="bankText"/>
	             </select>
             </div>
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-3">
            	 <div class="row">
            			<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">  
            				<input id="submitTimeStart" name="submitTimeStart" placeholder="开始时间" class="laydate-icon form-control">
            			</div>
            			<label class="hxleft">至</label>
	                  <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">  
	                  		<input id="submitTimeEnd" name="submitTimeEnd" placeholder="结束时间" class="laydate-icon form-control">
	                  </div>
                 </div>
             </div>
             <div class="col-xs-12 col-sm-12 col-md-12 col-lg-4">
	              <button type="button" class="btn dpbtn_blue_null" onclick="query(0,0);">当日</button>
	              <button type="button" class="btn dpbtn_blue_null" onclick="query(-1,-1);">昨日</button>
	              <button type="button" class="btn dpbtn_blue_null" onclick="query(-6,0);">近7日</button>
	              <button type="button" class="zhixcx" onclick="query();">执行查询</button>
         	</div>
   		</div>
   </div>
   <!--  
   <div class="business-padding">
   	  <button type="button" class="btn dpbtn_green" onclick="extFenPei();">申请分配</button>
   </div>	
   -->
   <div class="ibox-content">
     	<div class="jqGrid_wrapper">
         <table id="table_list_1"></table>
         <div id="pager_list_1"></div>
    	</div>
   </div>
</div>

	<!-- public quote -->
    <%@include file="/jsp/comm_js_include.jsp"%>
	<!-- jqGrid -->
    <script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/grid.locale-cn.min.js"></script>
    <!-- layerDate plugin javascript -->
    <script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>


	<script type="text/javascript">

		var winWidth = $(window).width();
		var winHeight = $(window).height();
	
		jQuery(function($){
			
			//外部js调用
		    laydate({
		        elem: '#submitTimeStart',
		        event: 'focus'
		    });
	
		    laydate({
		        elem: '#submitTimeEnd',
		        event: 'focus'
		    });
	
			getData();
		});
	
		var bclayer;
	    var getData = function()
	    {
	    	var winWidth = $('div.ibox-content').width();
	    	var winHeight = document.body.offsetHeight - 320;
	    	var win = winWidth / 8 - 10;
		 	$.jgrid.defaults.styleUI = 'Bootstrap';
	
		  jQuery("#table_list_1").jqGrid
		  ({
			url:'${basePath}/YwShenQingZxController/getList?examineStatus=M_zxcxfk',
	        datatype : "json",
	        colNames : [ 'replaceId','tid','hid', 'timeFlag','operatorId','业务提交时间','部门','业务员','客户姓名','角色', '身份证号码', '银行','锁单人'],
	        colModel : [
	                     {name: 'replaceId', index: '', hidden:true},
	                     {name: 'tid', index: '', hidden:true},
	                     {name: 'hid', index: '', hidden:true},
	                     {name: 'timeFlag',index: '',width: win,hidden:true},
	                     {name: 'operatorId',index: '',width: win,hidden:true},
	                     {name: 'created',index: '',width: win,align: "center",sortable: false},
	                     {name: 'name',index: '',width: win,align: "center",sortable: false},
	                     {name: 'creatorName',index: '',width: win,align: "center",sortable: false},
	                     {name: 'cusName',index: '',width: win,align: "center",sortable: false},
	                     {name: 'creditPeopleType',index: '',width: win,align: "center",sortable: false,
	                    	 formatter: function (cellvalue, options, rowObject) 
	                    	 {
	                    		 if(cellvalue == "01")
	                    		 {
	                    			 return "配偶";
	                    		 }
	                    		 
	                    		 if(cellvalue == "02")
	                    		 {
	                    			 return "担保人";
	                    		 }
	                    		 
	                    		 if(cellvalue == "03")
	                    		 {
	                    			 return "主借人";
	                    		 }
	                    	 }	 
	                     },
	                     {name: 'cusNo',index: '',width: win,align: "center",sortable: false},
	            		 {name: 'bankCode',index: '',width: win,align: "center",sortable: false},
	            		 {name: 'operatorName',index: '',width: win,align: "center",sortable: false,
	            			 formatter: function (cellvalue, options, rowObject) 
	            			 {
	            				 if(rowObject.operatorId)
	            				 {
	            					 if('${current_user_key.id}' == rowObject.operatorId)
		            				 {
		            					 return '<div style="color: #32C5D2;">'+rowObject.operatorName+'</div>';
		            				 }
	            					 
	            					 return '<div style="color: #659BE0;">'+rowObject.operatorName+'</div>';
	            				 }
	            				 return '<div style="color: #000;">未锁单</div>';
	            			 } 
	            		 }
	                   ],
	          mtype : "post",
	          height: winHeight,
	          width:winWidth,  
	          shrinkToFit:false,
	          autoScroll: false,
	          rowNum: 15,
	          rowList: [15, 30, 45],
	          viewrecords: true,
	          pager: "#pager_list_1",
	          hidegrid: false,
	          multiselect : false,
	          altRows:true,
	          altclass:'someClass',
	          ondblClickRow:function(rowId)
	          {
		        	var row = $("#table_list_1").jqGrid("getRowData",rowId);
		        	
		        	if(row.operatorId)
		        	{
		        		if(row.operatorId != '${current_user_key.id}')
		        		{
		        			layer.msg("其他人已经在查询征信结果", {icon: 1});
		        			return;
		        		}
		        	}
		        	var cusName =row.cusName;
					bclayer = layer.open({
					  title:'征信查询&反馈_'+cusName,
					  type: 2,
					  area: ['95%', '95%'], //宽高
					  content:'${basePath}/YwShenQingZxView/zxQueryCreditSearchlayer?id='+row.tid+"&tid="+row.replaceId+"&hid="+row.hid+"&creditPeopleType="+row.creditPeopleType+"&zxcxApplyId="+row.tid,
					  end: function () 
			    	  {
			    		  refresh();
			          }
					});
	          },
	          gridComplete:function()
	          {
	        	  var ids = $("#table_list_1").getDataIDs();
	        	  for(var i=0;i<ids.length;i++)
	        	  {
	        		  var row = $("#table_list_1").getRowData(ids[i]);
	        		  if(row.timeFlag == 1)
	        		  {
	        			  $('#'+ids[i]).find("td").css("color", "#ED6B75");
	        		  }
	        	  }
	          },
	          jsonReader : {
	        	  root:"result.rows",
	        	  page: "result.page",
	        	  total: "result.total",
	        	  records: "result.records",
	        	  repeatitems: false,
	        	  id: "replaceId"
	          },
	          loadComplete:function(datas){
	        	  if (datas.flag == "100100") {
	 				  layer.msg("查询成功!", {icon: 1, time: 1000});
	                  if($('#bankText').val() == "")
	                  {
	                	  var d = datas.loan_bank;
	                      var objs = '';
	                      for(var key in d)
	                      {
	                    	  objs += '<option value="'+key+'">'+d[key]+'</option>';
	                      }
	                      $('#bankName').html(objs);
	                      $('#bankText').val(objs);
	                  }
	                  return;
	              }
	        	  if(datas.flag == '100802') {
					  top.location.href = thisLoginUrl;
					  return;
				  }
	              layer.msg(datas.message, {icon: 2});
	          }
	      });
	    }
	
	    window.onresize = function()
	    {
	    	$("#table_list_1").setGridWidth($(window).width()-80);
	    }
	
	    var refresh = function()
	    {
	    	$("#table_list_1").jqGrid("setGridParam", { search: true }).trigger("reloadGrid", []);
	    }
	    
	    
	    //查询
	    var query = function(start,end)
	    {
	    	if(start != null && typeof start != 'undefined') {
	    		document.getElementById('submitTimeStart').value = laydate.now(start);
	    		document.getElementById('submitTimeEnd').value = laydate.now(end);
	    	} 
	    	var postData = $("#table_list_1").jqGrid("getGridParam", "postData");
	    	var customerName = document.getElementById('customerName').value || '';
	    	var salesmanName = document.getElementById('salesmanName').value || '';
	    	var bankName = document.getElementById('bankName').value || '';
	    	var submitTimeStart = document.getElementById('submitTimeStart').value || '';
	    	var submitTimeEnd = document.getElementById('submitTimeEnd').value || '';
	    	$.extend(postData,{"cus_name":customerName.trim(),"creator_name":salesmanName,"bank_code":bankName,"date_flag":"","submitTimeStart":submitTimeStart,"submitTimeEnd":submitTimeEnd});
	    	refresh();
	    }
	    
	    //导出分配的用户信息
	    var extFenPei = function()
	    {
	    	layer.prompt({title: '输入派单数量，并确认？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>'}, function(pass, index){
	    		if(pass == "")
	    		{
	    			layer.msg("请输入数字！", {icon: 1});
	    			return;
	    		}
	    		
	    		if(isNaN(pass))
	    		{
	    			layer.msg("请输入数字！", {icon: 1});
	    			return;
	    		}
	    		
	    		if(pass < 1)
	    		{
	    			layer.msg("请输入大于1的数字！", {icon: 1});
	    			return;
	    		}
	    		$.dpAjax({
	    	   		url:'${basePath}/YwShenQingZxController/extZhengxin',
	    	   		data:{"pass":pass},
	    			success: function(datas){
	    		 	  if(datas.flag == "100100")
	    		 	  {
	    		 		  layer.close(index);
	    		 		  setTimeout(function () {
	    		 			 refresh();
	    		 		  }, 1000);
	    				  return;
	    			  }
	    			  layer.msg(datas.message, {icon: 1});
	    			}
	    	   	});
	    	});
	    }
</script>
</body>
</html>
